Kate Culhane, Dept. of Ecology, Evolution, and Marine Biology, UC Santa Barbara
kathrynculhane@ucsb.edu
Summary
Exploring the data
##### PACKAGES #####
library(tidyverse) # data manipulation & visualization
library(vegan) # community analysis
##### DATA #####
# Metadata
meta <- read_csv("data_raw/field/naxos_meta.csv")
# Stomach pumping
diet_dat <- read_csv("output/02_diet.csv")
# Available prey community
prey_meta <- read_csv("output/02_prey_meta.csv")
prey_p <- read_csv("output/02_prey_p.csv")
prey_s <- read_csv("output/02_prey_s.csv")# Data wrangling
prey_p_long <- prey_p %>%
select(-gecko, -lizard) %>%
pivot_longer(6:29, names_to = "order", values_to = "count")
prey_s_long <- prey_s %>%
select(-gecko) %>%
pivot_longer(6:23, names_to = "order", values_to = "count")
prey <- full_join(prey_p_long, prey_s_long) %>%
full_join(meta[2:4]) %>%
filter(count != 0) %>%
mutate(site_type = paste0(use, "-use-", veg, "-veg"))
diet <- diet_dat %>%
select(-c(33:43)) %>%
pivot_longer(5:32, names_to = "order", values_to = "count") %>%
full_join(meta[2:4]) %>%
filter(count != 0) %>%
mutate(site_type = paste0(use, "-use-", veg, "-veg"))Abundance
# Summary table
prey %>%
group_by(order, trap_type) %>%
summarise(n = sum(count)) %>%
pivot_wider(names_from = trap_type, values_from = n) %>%
mutate(total = pitfall + sticky) %>%
arrange(-total)P/A
# Summary table
prey %>%
group_by(order, trap_type) %>%
summarise(n = length(count)) %>%
pivot_wider(names_from = trap_type, values_from = n) %>%
mutate(total = pitfall + sticky) %>%
arrange(-total)prey %>%
# wrangle data
group_by(use, veg, trap_type, site, sampleID) %>%
summarise(n = sum(count)) %>%
# plot
ggplot(aes(x = trap_type, y = n)) +
geom_jitter(aes(color = site),
width = 0.1, size = 1.5) +
geom_boxplot(fill = NA, outlier.shape = NA) +
theme_classic() +
theme(legend.position = 'NA',
axis.text.y = element_text(size = 9),
axis.text.x = element_text(size = 9)) +
labs(x='', y='Total abundance (indv/site)') +
facet_grid(rows = vars(use), cols = vars(veg))diet %>%
group_by(order) %>%
summarise(n = sum(count))diet %>%
# wrangle data
group_by(use, veg, site, lizard_id) %>%
summarise(n = sum(count)) %>%
# plot
ggplot(aes(x = 1, y = n)) +
geom_jitter(aes(color = site),
width = 0.1, size = 1.5) +
geom_boxplot(fill = NA, outlier.shape = NA) +
theme_classic() +
theme(legend.position = 'NA',
axis.text.y = element_text(size = 9),
axis.text.x = element_text(size = 9)) +
labs(x='', y='Total abundance (indv/site)') +
facet_grid(rows = vars(use), cols = vars(veg))# Site by species matrix
matrix <- as.matrix(matrix_df[-c(1,2)])
rownames(matrix) <- matrix_df$site
matrix_hell <- decostand(matrix, 'hellinger') # Hellinger transformation
# Severity data frame
sevs <- select(matrix_df, site, severity)# NMDS with relative abundance data (2 dimensions)
set.seed(17)
ord <- metaMDS(matrix_hell,
distance = 'bray',
autotransform = FALSE,
k = 3, # number of dimensions
try=50)
ord$stress # 0.096# Stress plot
stressplot(ord)
# Scree plot to check stress per number of dimensions
dimcheckMDS(matrix_hell, distance = "bray", autotransform = FALSE, k = 10, trymax = 20)cols <- c('darkgreen', 'orange', 'red')
par(mar = c(4,4,1,1))
plot(ord, display = 'species', type = 'n')
points(ord, display = 'sites',
cex = 1.5, pch = 19, col = cols[sevs$severity])
ordiellipse(ord, groups = sevs$severity,
label = TRUE, col = cols, lwd = 2)
text(ord, display = 'species',
cex = 0.6)taxa abundances ~ land use + veg + RANDOM:site
Combine pitfall/sticky? Use rel abundance or PA? Is it fine to use a trap as a sample with site as a RE?
taxa abundances ~ land use + veg + RANDOM:site
Use rel abundance or PA? Is it fine to use a lizard as a sample with site as a RE?
Method???
devtools::session_info()## - Session info ----------------------------------------------------------------------------------------------------
## setting value
## version R version 4.1.0 (2021-05-18)
## os Windows 10 x64
## system i386, mingw32
## ui RStudio
## language (EN)
## collate English_United States.1252
## ctype English_United States.1252
## tz America/Los_Angeles
## date 2021-07-19
##
## - Packages --------------------------------------------------------------------------------------------------------
## ! package * version date lib source
## P assertthat 0.2.1 2019-03-21 [?] CRAN (R 4.1.0)
## P backports 1.2.1 2020-12-09 [?] CRAN (R 4.1.0)
## P broom 0.7.8 2021-06-24 [?] CRAN (R 4.1.0)
## P cachem 1.0.5 2021-05-15 [?] CRAN (R 4.1.0)
## P callr 3.7.0 2021-04-20 [?] CRAN (R 4.1.0)
## P cellranger 1.1.0 2016-07-27 [?] CRAN (R 4.1.0)
## P cli 3.0.0 2021-06-30 [?] CRAN (R 4.1.0)
## P cluster 2.1.2 2021-04-17 [?] CRAN (R 4.1.0)
## P colorspace 2.0-2 2021-06-24 [?] CRAN (R 4.1.0)
## P crayon 1.4.1 2021-02-08 [?] CRAN (R 4.1.0)
## P DBI 1.1.1 2021-01-15 [?] CRAN (R 4.1.0)
## P dbplyr 2.1.1 2021-04-06 [?] CRAN (R 4.1.0)
## P desc 1.3.0 2021-03-05 [?] CRAN (R 4.1.0)
## P devtools 2.4.2 2021-06-07 [?] CRAN (R 4.1.0)
## P digest 0.6.27 2020-10-24 [?] CRAN (R 4.1.0)
## P dplyr * 1.0.7 2021-06-18 [?] CRAN (R 4.1.0)
## P ellipsis 0.3.2 2021-04-29 [?] CRAN (R 4.1.0)
## P evaluate 0.14 2019-05-28 [?] CRAN (R 4.1.0)
## P fansi 0.5.0 2021-05-25 [?] CRAN (R 4.1.0)
## P farver 2.1.0 2021-02-28 [?] CRAN (R 4.1.0)
## P fastmap 1.1.0 2021-01-25 [?] CRAN (R 4.1.0)
## P forcats * 0.5.1 2021-01-27 [?] CRAN (R 4.1.0)
## P fs 1.5.0 2020-07-31 [?] CRAN (R 4.1.0)
## P generics 0.1.0 2020-10-31 [?] CRAN (R 4.1.0)
## P ggplot2 * 3.3.5 2021-06-25 [?] CRAN (R 4.1.0)
## P glue 1.4.2 2020-08-27 [?] CRAN (R 4.1.0)
## P gtable 0.3.0 2019-03-25 [?] CRAN (R 4.1.0)
## P haven 2.4.1 2021-04-23 [?] CRAN (R 4.1.0)
## P highr 0.9 2021-04-16 [?] CRAN (R 4.1.0)
## P hms 1.1.0 2021-05-17 [?] CRAN (R 4.1.0)
## P htmltools 0.5.1.1 2021-01-22 [?] CRAN (R 4.1.0)
## P httr 1.4.2 2020-07-20 [?] CRAN (R 4.1.0)
## P jsonlite 1.7.2 2020-12-09 [?] CRAN (R 4.1.0)
## P katereR 0.1.0 2021-07-15 [?] Github (katekathrynkat/katereR@a771b5e)
## P knitr 1.33 2021-04-24 [?] CRAN (R 4.1.0)
## P labeling 0.4.2 2020-10-20 [?] CRAN (R 4.1.0)
## P lattice * 0.20-44 2021-05-02 [?] CRAN (R 4.1.0)
## P lifecycle 1.0.0 2021-02-15 [?] CRAN (R 4.1.0)
## P lubridate 1.7.10 2021-02-26 [?] CRAN (R 4.1.0)
## P magrittr 2.0.1 2020-11-17 [?] CRAN (R 4.1.0)
## P MASS 7.3-54 2021-05-03 [?] CRAN (R 4.1.0)
## P Matrix 1.3-3 2021-05-04 [?] CRAN (R 4.1.0)
## P memoise 2.0.0 2021-01-26 [?] CRAN (R 4.1.0)
## P mgcv 1.8-35 2021-04-18 [?] CRAN (R 4.1.0)
## P modelr 0.1.8 2020-05-19 [?] CRAN (R 4.1.0)
## P munsell 0.5.0 2018-06-12 [?] CRAN (R 4.1.0)
## P nlme 3.1-152 2021-02-04 [?] CRAN (R 4.1.0)
## P permute * 0.9-5 2019-03-12 [?] CRAN (R 4.1.0)
## P pillar 1.6.1 2021-05-16 [?] CRAN (R 4.1.0)
## P pkgbuild 1.2.0 2020-12-15 [?] CRAN (R 4.1.0)
## P pkgconfig 2.0.3 2019-09-22 [?] CRAN (R 4.1.0)
## P pkgload 1.2.1 2021-04-06 [?] CRAN (R 4.1.0)
## P prettyunits 1.1.1 2020-01-24 [?] CRAN (R 4.1.0)
## P processx 3.5.2 2021-04-30 [?] CRAN (R 4.1.0)
## P ps 1.6.0 2021-02-28 [?] CRAN (R 4.1.0)
## P purrr * 0.3.4 2020-04-17 [?] CRAN (R 4.1.0)
## P R6 2.5.0 2020-10-28 [?] CRAN (R 4.1.0)
## P Rcpp 1.0.6 2021-01-15 [?] CRAN (R 4.1.0)
## P readr * 1.4.0 2020-10-05 [?] CRAN (R 4.1.0)
## P readxl 1.3.1 2019-03-13 [?] CRAN (R 4.1.0)
## P remotes 2.4.0 2021-06-02 [?] CRAN (R 4.1.0)
## renv 0.13.2 2021-03-30 [1] CRAN (R 4.1.0)
## P reprex 2.0.0 2021-04-02 [?] CRAN (R 4.1.0)
## P rlang 0.4.11 2021-04-30 [?] CRAN (R 4.1.0)
## P rmarkdown 2.9 2021-06-15 [?] CRAN (R 4.1.0)
## P rprojroot 2.0.2 2020-11-15 [?] CRAN (R 4.1.0)
## P rstudioapi 0.13 2020-11-12 [?] CRAN (R 4.1.0)
## P rvest 1.0.0 2021-03-09 [?] CRAN (R 4.1.0)
## P scales 1.1.1 2020-05-11 [?] CRAN (R 4.1.0)
## P sessioninfo 1.1.1 2018-11-05 [?] CRAN (R 4.1.0)
## P stringi 1.6.2 2021-05-17 [?] CRAN (R 4.1.0)
## P stringr * 1.4.0 2019-02-10 [?] CRAN (R 4.1.0)
## P testthat 3.0.4 2021-07-01 [?] CRAN (R 4.1.0)
## P tibble * 3.1.2 2021-05-16 [?] CRAN (R 4.1.0)
## P tidyr * 1.1.3 2021-03-03 [?] CRAN (R 4.1.0)
## P tidyselect 1.1.1 2021-04-30 [?] CRAN (R 4.1.0)
## P tidyverse * 1.3.1 2021-04-15 [?] CRAN (R 4.1.0)
## P usethis 2.0.1 2021-02-10 [?] CRAN (R 4.1.0)
## P utf8 1.2.1 2021-03-12 [?] CRAN (R 4.1.0)
## P vctrs 0.3.8 2021-04-29 [?] CRAN (R 4.1.0)
## P vegan * 2.5-7 2020-11-28 [?] CRAN (R 4.1.0)
## P withr 2.4.2 2021-04-18 [?] CRAN (R 4.1.0)
## P xfun 0.24 2021-06-15 [?] CRAN (R 4.1.0)
## P xml2 1.3.2 2020-04-23 [?] CRAN (R 4.1.0)
## P yaml 2.2.1 2020-02-01 [?] CRAN (R 4.1.0)
##
## [1] C:/Users/kathr/Documents/git-repos/lizard-guts-naxos/renv/library/R-4.1/i386-w64-mingw32
## [2] C:/Users/kathr/AppData/Local/Temp/Rtmp4uARiT/renv-system-library
##
## P -- Loaded and on-disk path mismatch.